<?
layout("/inc/layout.html",{title:sysTitle}){
?>
<script type="text/javascript" src="static/My97DatePicker/WdatePicker.js"></script>
<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">门户内容管理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>门户内容管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">导航条管理</li>
		</ol>

		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">


		<div class="row mbl" >
			<div class="col-lg-12">
					<table style="width: 95%;margin-top: 20px;">
						<tr height="50">
							<td align="right" style="width: 100px;">中文名称&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="nameZh" name="title" /></td> 
							<td align="right" style="width: 100px;">英文名称&nbsp;&nbsp;</td>
							<td><input type="text" class="form-control" style="width: 100%;" id="nameEn" name="source" /></td>
							<td align="right">
								<button type="button"  data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="demo('1')">查询</button>
								<button type="button"  data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="addNavbar('0')">添加导航条</button>
							</td>
						</tr>
					</table>
			</div>
		</div>

		<table
			class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
			<thead>
				<tr>
					<th >序号</th>
					<th >中文名称</th>
					<th >英文名称 </th>
					<th >显示位置</th>
					<th >类型</th>
					<th >状态</th> 
					<th >可操作</th>
				</tr>
			</thead>
			<tbody id="findUser">
			</tbody>
		</table>
		<div id="dataNull" class="panel-body"
				style="height: 90px; line-height: 50px;" align="center">
		</div>
		<div id="page2" style="text-align: center; margin-top: 20px;"></div>
	</div>

	<!--END CONTENT-->
</div>


<?} ?>
<script>
	var curr;
	var id;
	$(function() {
		demo(1);
	});
	function get() {
		demo1(curr);
	}
	function getlay() {
		return id;
	}
	function addNavbar(lid){
		id = lid;
		layer.open({
			type : 2,
			area : [ '800px', '630px' ],
		    scrollbar: false,
		    shadeClose: true,
			fix : false, //不固定
			title : '新增或修改',
			//maxmin : true,  
			skin: 'layui-layer-rim', //加上边框
    	    btn : [ '保存 ', '关闭' ],
			content : ["cms-navbar-addUpload.html",'no'],
			yes : function(index, layer) {
				 var iframeWin = parent.window[layer.find('iframe')[0]['name']];
				 iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	}
	
	function demo(curr) {
		$.ajax({
			type : "post",
			url : "queryCmsNavbar.do",
			data : {
				"page" : curr || 1,
				"nameZh" : $("#nameZh").val(),
				"nameEn" : $("#nameEn").val()
			},
			dataType : "json",
			traditional : true,
			success : function(data) {
				//alert(JSON.stringify(res));
				//此处仅仅是为了演示变化的内容
				var str = "";
				$("#findUser").html("");
				if(data.data.length>0){
					$("#dataNull").html("");
				}else{
					$("#dataNull").html("<span class='subtitle' style='font-size: 15px;'>数据为空!</span>");
				}
				for ( var i = 0; i < data.data.length; i++) {
					var start='';
					str += "<tr><td>"
							+ (i + 1)
							+ "</td><td> <label id=>"
							+ data.data[i].nameZh
							+ "</label></td><td><label >"
							+ data.data[i].nameEn
							+ "</label></td><td><label >"
							+ data.data[i].showLocation
							+ "</label></td><td><label >"
							+ data.data[i].type
							+ "</label></td><td><label >"
							+ data.data[i].status
							+ "</label></td><td>"
							+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"addNavbar('"
							+ data.data[i].id
							+ "')\">"
							+ "修改"
							+ "</button>&nbsp;&nbsp;"
							+ "<button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"deleteNavbar('"
							+ data.data[i].id
							+ "')\">"
							+ "删除"
							+ "</button>"
							+ "</td></tr>";
				}
				$("#findUser").append(str);

				laypage({
					cont : document.getElementById('page2'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : (Math.ceil(data.count/15)), //总页数
					skip : true, //是否开启跳页
					skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
					curr: curr || 1,
					last: false,
					groups : 6,//连续显示分页数
					jump : function(obj, first) { //触发分页后的回调
						if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
							demo(obj.curr);
							 var curr = obj.curr;
			                 curr=obj.curr;
						}
					}
				});
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	};
	//删除
	function deleteNavbar(delId){
	if (confirm("是否确认删除！！")) {
		$.ajax({
			type : "post",
			url : "deleteCmsNavbar.do",
			data : {
				"id":delId,
			},
			dataType : "json",
			traditional : true,
			success : function(data) {
				if(data.msg == "OK"){
					layer.msg('删除成功！');
				}else{
					layer.msg('删除失败！');
				}
				demo();
			},
			error : function(data) {
				alert("请求失败");
			}
		});
		}
	}
</script>